{% extends "base.html" %}

{% block content %}

<style>
form{margin:0px;}
.bc{background-color:#ffffff;line-height:25px;}
.bc0{background-color:#ffffff;line-height:25px;}
.bc1{background-color:#991100;line-height:25px;color:#ffffff}
.bc2{background-color:#ffdddd;line-height:25px;}
.bc3{background-color:#ffffbb;line-height:25px;}
.bc4{background-color:#11cc00;line-height:25px;}
.bc5{background-color:#DAEEFE;line-height:25px;}
.bcgray{background-color:#cccccc;line-height:25px;color:#ffffff}
.bcblack{background-color:#000000;line-height:25px;color:#ffffff}
td{
word-wrap:break-word;
}
.bc1 a:link{color:#ffffff}
.bc1 a:visited{color:#ffffff}


.bc4 a:link{color:#ffffff}
.bc4 a:visited{color:#ffffff}

.bcgray a:link{color:#ffffff}
.bcgray a:visited{color:#ffffff}
.bcblack a:link{color:#ffffff}
.bcblack a:visited{color:#ffffff}
#w150
{width:150px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}

/*MyTips*/
#popupcontainer {
	height: auto;
	width: 180px;
	z-index: 100;
}
#popupcontent {
	text-align:left;
	height: auto;
	width: auto;
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	color: #0052FF;
	position: relative;
	top: 0px;
	left: 0px;
	padding: 12px 15px 0px 10px;
	border: none;
	background-image: url('/static/images/mytiptop.png');
}
* html #popupcontent {
	filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop src='/static/images/mytiptop.png');
	background-image: none;
	height:100%;
}
#popupbottom {
	position: relative;
	width: 180px;
	height: 18px;
	background-image: url('/static/images/mytipbottom.png');
}
</style>
<script language="javascript" src="/static/js/jquery-1.2.1.pack.js" type="text/javascript"></script>
<script type="text/javascript" src="/static/js/jquery-calendar-pack.js" ></script>
<script type="text/javascript" src="/static/js/urltip.js" ></script>
<script type="text/javascript" src="/static/js/ajax.js" ></script>
<style type="text/css">@import url(/static/css/jquery-calendar.css);</style>
<script language="javascript" type="text/javascript">
$(document).ready
(
function()
{
    	popUpCal.regional['zh-cn'] = {
		dateFormat: 'YMD-'};
	popUpCal.setDefaults(popUpCal.regional['zh-cn']);
   $('#start_date').calendar({autoPopUp: 'focus',yearRange: '-10:+0'});
	$('#end_date').calendar({autoPopUp: 'focus',yearRange: '-10:+0'});
	$('#last_contact').calendar({autoPopUp: 'focus',yearRange: '-10:+0'});
	$("#programt").html($("#p_id [selected]").text());
	//$("#programt").text(title);
$('#search').click(function(){
var sales = encodeURIComponent($("#sales").val());
var name = encodeURIComponent($("#name").val());
var tel = encodeURIComponent($("#tel").val());
var email = encodeURIComponent($("#email").val());
var followupremark = encodeURIComponent($("#followupremark").val());
p_id = $("#p_id").val();
a_id = $("#a_id").val();
f_id = $("#f_id").val();
inter = $("#sinterlevel").val();
statu = $("#sstatus1").val();
start_date=$("#start_date").val();
end_date=$("#end_date").val();
last_contact=$("#last_contact").val();
var url = "/u/search/?page=1" + "&p_id=" + p_id + "&a_id=" + a_id + "&f_id=" + f_id +"&sales=" + sales +"&name=" + name +"&tel=" + tel +"&email=" + email +"&interlevel=" + inter +"&status=" + statu+"&start_date=" + start_date +"&end_date=" + end_date + "&last_contact=" + last_contact+ "&followupremark=" + followupremark;
window.location=url;
});
$('#getmail').click(function(){
var sales = encodeURIComponent($("#sales").val());
var name = encodeURIComponent($("#name").val());
var tel = encodeURIComponent($("#tel").val());
var email = encodeURIComponent($("#email").val());
var followupremark = encodeURIComponent($("#followupremark").val());
p_id = $("#p_id").val();
a_id = $("#a_id").val();
f_id = $("#f_id").val();
inter = $("#sinterlevel").val();
statu = $("#sstatus1").val();
start_date=$("#start_date").val();
end_date=$("#end_date").val();
last_contact=$("#last_contact").val();
statused=$("#statused").val();
var url = "/u/mail/" + "?p_id=" + p_id + "&a_id=" + a_id + "&f_id=" + f_id +"&sales=" + sales +"&name=" + name +"&tel=" + tel +"&email=" + email +"&interlevel=" + inter +"&status=" + statu+"&start_date=" + start_date +"&end_date=" + end_date + "&last_contact=" + last_contact+ "&followupremark=" + followupremark+ "&statused=" + statused;
//alert(url);
//window.open(url, "_blank", "top=20");
window.location=url;
});
$('#getpost').click(function(){
var sales = encodeURIComponent($("#sales").val());
var name = encodeURIComponent($("#name").val());
var tel = encodeURIComponent($("#tel").val());
var email = encodeURIComponent($("#email").val());
var followupremark = encodeURIComponent($("#followupremark").val());
p_id = $("#p_id").val();
a_id = $("#a_id").val();
f_id = $("#f_id").val();
inter = $("#sinterlevel").val();
statu = $("#sstatus1").val();
start_date=$("#start_date").val();
end_date=$("#end_date").val();
last_contact=$("#last_contact").val();
statused=$("#statused").val();
var url = "/u/post/" + "?p_id=" + p_id + "&a_id=" + a_id + "&f_id=" + f_id +"&sales=" + sales +"&name=" + name +"&tel=" + tel +"&email=" + email +"&interlevel=" + inter +"&status=" + statu+"&start_date=" + start_date +"&end_date=" + end_date + "&last_contact=" + last_contact+ "&followupremark=" + followupremark+ "&statused=" + statused;
//alert(url);
//window.open(url, "_blank", "top=20");
window.location=url;
});
   });
function changestatus(e,id,cfm,back)
	{
	  if (confirm(cfm))
		{
		$.post("/changestatus/",{id:id,value:$(e).val()},function(data){
		if(data == "ok")
		{
			alert('ok');
		}
		if(data != "ok")
		{
		alert(data);
		$(e).val(back);
		}});
		}
	else
	$(e).val(back);
	}
function changelevel(e,id,cfm,back)
	{
	  if (confirm(cfm))
		{
		$.post("/changelevel/",{id:id,value:$(e).val()},function(data){
		if(data == "ok")
		$(e).parent().parent().attr("class","bc"+$(e).val());
		else
		{
		alert(data);
		$(e).val(back);
		}
		});
		}
	else
	{
	$(e).val(back);
	}
	}

function checkstatused()
{
var u;
u=document.getElementById("utinfo");
if (u.checked)
{
document.getElementById("statused").value=1;
}
else
{
document.getElementById("statused").value=0;
}
}
 </script>
<SCRIPT language=javascript>function T(n){document.getElementById("ArticleCnt").style.fontSize=n+"px";}</SCRIPT>
<BODY>
<SCRIPT>  
function srcMarquee(){
this.ID = document.getElementById(arguments[0]);
if(!this.ID){this.ID = -1;return;}
this.Direction = this.Width = this.Height = this.DelayTime = this.WaitTime = this.Correct = this.CTL = this.StartID = this.Stop = this.MouseOver = 0;
this.Step = 1;
this.Timer = 30;
this.DirectionArray = {"top":0 , "bottom":1 , "left":2 , "right":3};
if(typeof arguments[1] == "number")this.Direction = arguments[1];
if(typeof arguments[2] == "number")this.Step = arguments[2];
if(typeof arguments[3] == "number")this.Width = arguments[3];
if(typeof arguments[4] == "number")this.Height = arguments[4];
if(typeof arguments[5] == "number")this.Timer = arguments[5];
if(typeof arguments[6] == "number")this.DelayTime = arguments[6];
if(typeof arguments[7] == "number")this.WaitTime = arguments[7];
if(typeof arguments[8] == "number")this.ScrollStep = arguments[8]
this.ID.style.overflow = this.ID.style.overflowX = this.ID.style.overflowY = "hidden";
this.ID.noWrap = true;
this.IsNotOpera = (navigator.userAgent.toLowerCase().indexOf("opera") == -1);
if(arguments.length >= 7)this.Start();
}
srcMarquee.prototype.Start = function(){
if(this.ID == -1)return;
if(this.WaitTime < 800)this.WaitTime = 800;
if(this.Timer < 20)this.Timer = 20;
if(this.Width == 0)this.Width = parseInt(this.ID.style.width);
if(this.Height == 0)this.Height = parseInt(this.ID.style.height);
if(typeof this.Direction == "string")this.Direction = this.DirectionArray[this.Direction.toString().toLowerCase()];
this.HalfWidth = Math.round(this.Width / 2);
this.BakStep = this.Step;
this.ID.style.width = this.Width;
this.ID.style.height = this.Height;
if(typeof this.ScrollStep != "number")this.ScrollStep = this.Direction > 1 ? this.Width : this.Height;
var msobj = this;
var timer = this.Timer;
var delaytime = this.DelayTime;
var waittime = this.WaitTime;
msobj.StartID = function(){msobj.Scroll()}
msobj.Continue = function(){
if(msobj.MouseOver == 1){
setTimeout(msobj.Continue,delaytime);
     }
     else{ clearInterval(msobj.TimerID);
msobj.CTL = msobj.Stop = 0;
msobj.TimerID = setInterval(msobj.StartID,timer);
     }
    }
msobj.Pause = function(){
msobj.Stop = 1;
clearInterval(msobj.TimerID);
setTimeout(msobj.Continue,delaytime);
    }
msobj.Begin = function(){
   msobj.ClientScroll = msobj.Direction > 1 ? msobj.ID.scrollWidth : msobj.ID.scrollHeight;
   if((msobj.Direction <= 1 && msobj.ClientScroll <msobj.Height) || (msobj.Direction > 1 && msobj.ClientScroll <msobj.Width))return;
   msobj.ID.innerHTML += msobj.ID.innerHTML;
   msobj.TimerID = setInterval(msobj.StartID,timer);
   if(msobj.ScrollStep < 0)return;
   msobj.ID.onmousemove = function(event){
       if(msobj.ScrollStep == 0 && msobj.Direction > 1){
var event = event || window.event;
if(window.event){
if(msobj.IsNotOpera){msobj.EventLeft = event.srcElement.id == msobj.ID.id ? event.offsetX - msobj.ID.scrollLeft : event.srcElement.offsetLeft - msobj.ID.scrollLeft + event.offsetX;}
else{msobj.ScrollStep = null;return;}
}
else{msobj.EventLeft = event.layerX - msobj.ID.scrollLeft;}
msobj.Direction = msobj.EventLeft > msobj.HalfWidth ? 3 : 2;
msobj.AbsCenter = Math.abs(msobj.HalfWidth - msobj.EventLeft);
msobj.Step = Math.round(msobj.AbsCenter * (msobj.BakStep*2) / msobj.HalfWidth);
}
}
msobj.ID.onmouseover = function(){
if(msobj.ScrollStep == 0)return;
msobj.MouseOver = 1;
clearInterval(msobj.TimerID);
}
msobj.ID.onmouseout = function(){
if(msobj.ScrollStep == 0){
if(msobj.Step == 0)msobj.Step = 1;
return;
}
msobj.MouseOver = 0;
if(msobj.Stop == 0){
clearInterval(msobj.TimerID);
msobj.TimerID = setInterval(msobj.StartID,timer);
}}}
setTimeout(msobj.Begin,waittime);
}
srcMarquee.prototype.Scroll = function(){
switch(this.Direction){
case 0:
this.CTL += this.Step;
if(this.CTL >= this.ScrollStep && this.DelayTime > 0){
this.ID.scrollTop += this.ScrollStep + this.Step - this.CTL;
this.Pause();
return;
}
else{
if(this.ID.scrollTop >= this.ClientScroll){this.ID.scrollTop -= this.ClientScroll;}
this.ID.scrollTop += this.Step;
}
break;
case 1:
this.CTL += this.Step;
if(this.CTL >= this.ScrollStep && this.DelayTime > 0){
this.ID.scrollTop -= this.ScrollStep + this.Step - this.CTL;
this.Pause();
return;
}
else{
if(this.ID.scrollTop <= 0){this.ID.scrollTop += this.ClientScroll;}
this.ID.scrollTop -= this.Step;
}
break;
case 2:
this.CTL += this.Step;
if(this.CTL >= this.ScrollStep && this.DelayTime > 0){
this.ID.scrollLeft += this.ScrollStep + this.Step - this.CTL;
this.Pause();
return;
}
else{
if(this.ID.scrollLeft >= this.ClientScroll){this.ID.scrollLeft -= this.ClientScroll;}
this.ID.scrollLeft += this.Step;
}
break;
case 3:
this.CTL += this.Step;
if(this.CTL >= this.ScrollStep && this.DelayTime > 0){
this.ID.scrollLeft -= this.ScrollStep + this.Step - this.CTL;
this.Pause();
return;
}
else{
if(this.ID.scrollLeft <= 0){this.ID.scrollLeft += this.ClientScroll;}
this.ID.scrollLeft -= this.Step;
}
break;
}
} 
</SCRIPT>
<STYLE>
#Scroll {
CLEAR: both; PADDING-LEFT: 5px;PADDING-bottom: 5px; FONT-SIZE: 12px;MARGIN: 0px auto;  WIDTH: 98%; COLOR: #c2130e; LINE-HEIGHT: 25px;HEIGHT: 25px; TEXT-ALIGN: left
}
#Scroll A {
PADDING-RIGHT: 20px; PADDING-LEFT: 3px;LINE-HEIGHT: 25px;HEIGHT: 25px;COLOR: #fff; MARGIN-RIGHT: 3px; TEXT-DECORATION: none
}
#Scroll A.s_end {
PADDING-RIGHT: 0px; MARGIN-LEFT: 8px
}
</STYLE>
<script>
/*
function handle_get_new_customer(jsonOBJ)
{
	document.getElementById('newmemberslist').innerHTML=jsonOBJ['ok'];
}

function get_newcustomer()
{
	ajax.send('/get_new_customer/',
		handle_get_new_customer,'post',"sid=1"
	);
}
function gogetdata()
{
	get_newcustomer();
	window.setTimeout("gogetdata()",30000);
}
*/
</script>
<body onload="pltsinits();">
<div id="addmail"></div>
<div class="form-div">
  <form action="javascript:search()" name="searchForm">
    <img src="/static/images/icon_search.gif" width="26" height="22" border="0" alt="SEARCH" />
	Program:<select name="p_id" id="p_id"  style='color:#CC33FF'>
	<option value="0" {% ifequal p_id 0 %} selected="selected" {% endifequal %}>All</option>
{% for p in project_list %}
<option value="{{p.id}}" {% ifequal p.id p_id %} selected="selected" {% endifequal %}>{{p.name}}</option>
{% endfor %}
</select>
{% if is_p %} <input type='hidden' id="p_id" value="{{p_id}}" />{% endif %}
Agent:<select name="a_id" id="a_id" >
<option value="0" {% ifequal a_id '0' %} selected="selected" {% endifequal %}>All</option>
{% for a in agent_list %}
<option value="{{a.id}}" {% ifequal a.id a_id %} selected="selected" {% endifequal %}>{{a.name}}</option>
{% endfor %}
</select>
Sales:<input type="text" name="sales" id="sales" value="{{sales}}"  /><br />

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Name:<input type="text" name="name" id="name" value="{{name}}" />

Tel:<input type="text" name="tel" id="tel" value="{{tel}}" />
Email:<input type="text" name="email" id="email" value="{{email}}" />&nbsp;
Sales Comment:<input type="text" name="followupremark" id="followupremark" value="{{followupremark}}" /><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Interest Level:<select name="interlevel" id="sinterlevel"><option value="all" {% ifequal interlevel 'all' %} selected="selected" {% endifequal %}>All</option><option value="0" {% ifequal interlevel '0' %} selected="selected" {% endifequal %}>NC</option><option value="1" {% ifequal interlevel '1' %} selected="selected" {% endifequal %}>HI</option><option value="2" {% ifequal interlevel '2' %} selected="selected" {% endifequal %}> SI</option><option value="5" {% ifequal interlevel '5' %} selected="selected" {% endifequal %}>LI</option><option value="3" {% ifequal interlevel '3' %} selected="selected" {% endifequal %}>NI</option><option value="4" {% ifequal interlevel '4' %} selected="selected" {% endifequal %}>NT</option></select>

Follow_up Status:
	<select name="sstatus1" id="sstatus1">
		<option value="all" {% ifequal status 'all' %} selected="selected" {% endifequal %}>All</option>
		<option value="0" {% ifequal status '0' %} selected="selected" {% endifequal %}>Not yet</option>
		<option value="1" {% ifequal status '1' %} selected="selected" {% endifequal %}>Can't reach</option>
		<option value="2" {% ifequal status '2' %} selected="selected" {% endifequal %}>App sch'd</option>
		<option value="3" {% ifequal status '3' %} selected="selected" {% endifequal %}>Under cons</option>
		<option value="4" {% ifequal status '4' %} selected="selected" {% endifequal %}>Call later</option>
		<option value="5" {% ifequal status '5' %} selected="selected" {% endifequal %}>Conflict</option>
		<option value="6" {% ifequal status '6' %} selected="selected" {% endifequal %}>No call</option>
		<option value="7" {% ifequal status '7' %} selected="selected" {% endifequal %}> Enrolled</option>
		<option value="8" {% ifequal status '8' %} selected="selected" {% endifequal %}> Repeat</option>
		<option value="9" {% ifequal status '9' %} selected="selected" {% endifequal %}> Application</option>
		<option value="11" {% ifequal status '11' %} selected="selected" {% endifequal %}> Overseas</option>
		<option value="10" {% ifequal status '10' %} selected="selected" {% endifequal %}> Dead</option></select>

Further interest:<select name="f_id" id="f_id" >
<option value="0" {% ifequal f_id '0' %} selected="selected" {% endifequal %}>All</option>
{% for a in further_list %}
<option value="{{a.id}}" {% ifequal a.id f_id %} selected="selected" {% endifequal %}>{{a.name}}</option>
{% endfor %}</select>
<br />
&nbsp;&nbsp;&nbsp;&nbsp;From:<input type="text" id="start_date" name="start_date" value="{% if start_date %}{{start_date}}{% else %}begin{% endif %}" size="20" readonly="true"/>   To:<input type="text" id="end_date" name="end_date" value="{% if end_date %}{{end_date}}{% else %}now{% endif %}" size="20" readonly="true"/>    Last Contacted:<input type="text" id="last_contact" name="last_contact" value="{% if last_contact %}{{last_contact}}{% else %}none{% endif %}" size="20" readonly="true"/> <br>
<input type="button" value="Search" id='search' class="button"/>
&nbsp;&nbsp;<input type="checkbox" id="utinfo" name="utinfo" value="1" checked onclick="checkstatused();"  /><input type="hidden" name="statused" id="statused" value="1" />Enrolled&nbsp;<input type="button" value="Mail Address" id='getmail' class="button"/>&nbsp;&nbsp;<input type="button" value="Postal Address" id='getpost' class="button"/>
  </form>
</div>
<!--
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center" height="27">
		<DIV id=Scroll>
		<DIV id=ScrollMe style="OVERFLOW: hidden; HEIGHT: 27px">
				<div id="newmemberslist">
				</div>
		</DIV></DIV>
		<SCRIPT>new srcMarquee("ScrollMe",0,1,808,27,30,3000,3000,27)</SCRIPT>
		</DIV>
	</td>
	</tr>
	</table>
-->
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center">
<table width='98%'  cellspacing='1' align='center' class='grid'><tr><td {%ifequal p_id 0%}colspan='9'{%else%}colspan='8'{%endifequal%} class='title' align="center">users list(<span id='programt' style='color:#CC33FF'></span>)</td><td colspan='3' align="right"><a href='/program/'><font color=#CC33FF><strong>Change program</strong></font></a></tr>
<tr valign='middle' align='left'></tr>
  <tr valign='middle' align='center'>
  <td class='odd' width='5%'>ID</td>
<td class='even' width='8%'>Action</td>
  <td class='odd' {%ifequal p_id 0%}width='12%'{%else%}width='20%'{%endifequal%}>Name</td>
{%ifequal p_id 0%}<td class='even' width='10%'>Program</td>{%endifequal%}


<td class='even' width='10%'>Follow-up</td> 
<td class='odd' width='8%'>Agent</td>
<td class='even' width='5%'>Sales</td>
  <td class='odd' width='5%'>Interlevel</td>

<td class='even' width='9%'>Company/Address</td>
<td class='odd' width='8%'>TEL</td>
<td class='even' width='8%'>Email</td> 

<td class='odd' width='6%'>Regtime</td>  
<td class='even' width='4%'>To Student</td> 

  </tr>
  {% for members in members_list %}
 
  <tr valign='middle' align='left' {%if members.othercolor%} {%if members.isblack%} class='bcblack'{%else%}{%if members.isgray%}class='bcgray'{%endif%}{%endif%}{%else%}class='bc{{members.interlevel}}'{%endif%}>
  <td >{{members.id}}</td>
  <td  align='center'>{% ifequal level 'administrators' %}<a href="/edit_u/{{ members.id}}/?is_deal=1"><img src="/static/images/icon_edit.gif"border="0" alt="edit" title='edit'></a>&nbsp;<a href="/del_u/{{ members.id}}" onclick="return confirm('Are you sure to delete it?');"><img src="/static/images/icon_drop.gif" border="0" alt="delete" title='delete'></a>{%endifequal%}&nbsp;<img src="/static/images/mail.gif" border="0"  onclick="javascript:ajaxaddmail({{members.id}})" style="cursor:hand;" ></td>
   <td ><a title=" {{members.fu.timeline}}<br />{{members.fu.remarks}}" href="/edit_u/{{ members.id}}/?is_deal=1" >{{members.name}}</a> &nbsp;{%if members.is_today_follow%}<a title="Need to follow up today!<br>{{members.follow_remark}}" href="/edit_u/{{ members.id}}/?is_deal=1"><img src="/static/images/todaytime.gif" width="16" border="0" ></a>{%endif%}</td>
   {%ifequal p_id 0%}<td width='10%'>{{members.projects.name}}</td>{%endifequal%}
    <td align='center'><!-- {{members.get_status_display}} -->
		<select name="status" style="width:88px;" onchange="changestatus(this,{{members.id}}, 'are you sure?',{{members.status}})">
			<option value="0" {% ifequal members.status '0' %} selected="selected" {% endifequal %}>Not yet</option>
			<option value="1" {% ifequal members.status '1' %} selected="selected" {% endifequal %}>Can't reach</option>
			<option value="2" {% ifequal members.status '2' %} selected="selected" {% endifequal %}>App sch'd</option>
			<option value="3" {% ifequal members.status '3' %} selected="selected" {% endifequal %}>Under cons</option>
			<option value="4" {% ifequal members.status '4' %} selected="selected" {% endifequal %}>Call later</option>
			<option value="5" {% ifequal members.status '5' %} selected="selected" {% endifequal %}>Conflict</option>
			<option value="6" {% ifequal members.status '6' %} selected="selected" {% endifequal %}>No call</option>
			<option value="7" {% ifequal members.status '7' %} selected="selected" {% endifequal %}> Enrolled</option>
			<option value="8" {% ifequal members.status '8' %} selected="selected" {% endifequal %}> Repeat</option>
			<option value="9" {% ifequal members.status '9' %} selected="selected" {% endifequal %}> Application</option>
			<option value="11" {% ifequal members.status '11' %} selected="selected" {% endifequal %}> Overseas</option>
			<option value="10" {% ifequal members.status '10' %} selected="selected" {% endifequal %}> Dead</option>
		</select></td> 
	 <td >
		{% ifequal level 'administrators' %}<a href="/ulist/agent/{{ members.agent_id}}">{{members.agent.name}}</a>{%else%}{{members.agent.name}}{%endifequal%}
	</td>
	 <td >{% ifequal level 'administrators' %}<a href="/ulist/sales/{{ members.salesperson.id}}">{{members.salesperson.name}}</a>{%else%}{{members.salesperson.name}}{%endifequal%}</td>
  <td ><!-- {{members.get_interlevel_display}} --><select name="interlevel" onchange="changelevel(this,{{members.id}}, 'are you sure?',{{members.interlevel}})"><option value="0" {% ifequal members.interlevel '0' %} selected="selected" {% endifequal %}>NC</option><option value="1" {% ifequal members.interlevel '1' %} selected="selected" {% endifequal %}>HI</option><option value="2" {% ifequal members.interlevel '2' %} selected="selected" {% endifequal %}> SI</option><option value="5" {% ifequal members.interlevel '5' %} selected="selected" {% endifequal %}>LI</option><option value="3" {% ifequal members.interlevel '3' %} selected="selected" {% endifequal %}>NI</option><option value="4" {% ifequal members.interlevel '4' %} selected="selected" {% endifequal %}>NT</option></select></td>
 
<td ><div id="w150">{{members.company }} <br /> {{members.address }}</div></td> 
<td  >{{members.tel_h}}<br />{{members.tel_o}}<br />{{members.tel_m}}</td> 
<td  ><a href='mailto:{{members.email }}'>{{members.email }}</a></td> 

<td  align='center'>{{members.regtime|date:"m-d H:i" }}</td>
<td  align='center'><a href="/u/add_to_student/{{ members.id}}/" onclick="return confirm('Are you sure to add this customer to be a student?');">To</a></td>
  </tr>

  {% endfor %}


</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center">
<table width='98%'  cellspacing='1' align='center'><tr>
<td width="50%" bgcolor="#ffffff"><!-- <form name='form1' id='form1' action="/u/search/" method='post'>
<input type="text" name="keyword" value="" />
<select name="skind">
<option value="">Search Conditions</option>
<option value="byname">By Name</option>
<option value="byagent">By Agent Name</option>
<option value="bysales">By Sales Name</option>
<option value="byemail">By Email</option>
<option value="bytime">By Regtime</option>
</select>
<input type='submit' class='button' name='submit'  id='submit' value=' Search ' onclick="ccc(this.form,this)" />
</form> -->
</td>
<td bgcolor="#ffffff" width="50%" align="right"><strong>{{ hits }}</strong>&nbsp;Records&nbsp;&nbsp;{% if is_paginated %}
                    {% ifequal current_page 1 %}First 
                    {% else %} {% ifequal issearch "y" %}<a href="/u/search/?page=1&p_id={{p_id}}&a_id={{a_id}}&sales={{sales}}&name={{name}}&tel={{tel}}&email={{email}}&interlevel={{interlevel}}&status={{status}}&start_date={{start_date}}&end_date={{end_date}}&last_contact={{last_contact}}&followupremark={{followupremark}}">{% else %}<a href="/ulist/">{%endifequal%}First</a>
                    {% endifequal %}&nbsp;&nbsp;
                    {% if has_previous %} {% ifequal issearch "y" %}<a href="/u/search/?page={{ previous_page }}&p_id={{p_id}}&a_id={{a_id}}&sales={{sales}}&name={{name}}&tel={{tel}}&email={{email}}&interlevel={{interlevel}}&status={{status}}&start_date={{start_date}}&end_date={{end_date}}&last_contact={{last_contact}}&followupremark={{followupremark}}">Prev</a>{%else%}<a href="/ulist/{{ previous_page }}/">Prev</a>{%endifequal%}
                    {% else %} Prev
                    {% endif %}&nbsp;&nbsp;
                    {% if has_next %}{% ifequal issearch "y" %}<a href="/u/search/?page={{ next_page }}&p_id={{p_id}}&a_id={{a_id}}&sales={{sales}}&name={{name}}&tel={{tel}}&email={{email}}&interlevel={{interlevel}}&status={{status}}&start_date={{start_date}}&end_date={{end_date}}&last_contact={{last_contact}}&followupremark={{followupremark}}">Next</a>{%else%}<a href="/ulist/{{ next_page }}/">Next</a>{%endifequal%}
                    {% else %}Next
                    {% endif %}&nbsp;&nbsp;
                    {% ifequal current_page pages %}Last
                    {% else %} {% ifequal issearch "y" %}<a href="/u/search/?page={{ pages }}&p_id={{p_id}}&a_id={{a_id}}&sales={{sales}}&name={{name}}&tel={{tel}}&email={{email}}&interlevel={{interlevel}}&status={{status}}&start_date={{start_date}}&end_date={{end_date}}&last_contact={{last_contact}}&followupremark={{followupremark}}">Last</a>{%else%}<a href="/ulist/{{ pages }}/">Last</a>{%endifequal%}
                    {% endifequal %}
                    &nbsp;&nbsp;
                    Current:<select {% ifequal issearch "y"%}onchange="window.location='/u/search/?page='+this.value+'&p_id={{p_id}}&a_id={{a_id}}&sales={{sales}}&name={{name}}&tel={{tel}}&email={{email}}&interlevel={{interlevel}}&status={{status}}&start_date={{start_date}}&end_date={{end_date}}&last_contact={{last_contact}}&followupremark={{followupremark}}'"  {%else%}onchange="window.location='/ulist/' + this.value + '/'"{%endifequal%}>
					{% for x in page_numbers %}
					<option value="{{x}}" {% ifequal x current_page %} selected="selected" {% endifequal %}>{{x}}</option>
					{% endfor %}
          </select>             &nbsp;&nbsp;
                {% endif %}              
               </td></tr></table>
</td></tr></table>

<script type="text/javascript"> 
window.onload=function(){ 
	window.setTimeout("gogetdata()",2000);
//manage duplication of name
	var t = $('.grid').children().children('tr')
	for(var i=3;i<t.length;i++){
		var temp_name = $(t[i]).children('td')[2].children[0].innerHTML
		var temp_email = $(t[i]).children('td')[10].children[0].innerHTML
		var temp_phone = $(t[i]).children('td')[9].children[0].innerHTML
		var flag = i
		for (var j=i+1;j<t.length;j++){
			var c_name = $(t[j]).children('td')[2].children[0].innerHTML
			var c_email = $(t[j]).children('td')[10].children[0].innerHTML
			var c_phone = $(t[j]).children('td')[9].children[0].innerHTML
			if((c_name!='' && c_name == temp_name) || (c_phone != '' && c_phone == temp_phone) || (c_email!='' && c_email == temp_email)){
				$(t[j]).hide()
				$(t[j]).addClass('hidden_'+flag)
				if($($(t[flag]).children('td')[2]).find('span').length<1){
					$($(t[flag]).children('td')[2]).append('&nbsp;<span pid="'+flag+'" style="cursor:pointer;font-weight:900;font-size:16px;color:green;width:20px;height:20px;background:#cccccc;" class="show_hid">+</span>')
					$($(t[flag]).children('td')[2]).addClass('collapse')
				}
				i = j
			}else{
				break;
			}
		}
	}
	$('span.show_hid').click(function(){
		var cla = 'hidden_'+$(this).attr('pid')
		$('.'+cla).toggle();
		if($(this).html()=="+"){
			$(this).html('--')
		}else{
			$(this).html('+')
		}
	})
}
</script>
{% endblock %}